﻿using Microsoft.EntityFrameworkCore;
//数据库上下文 (DbContext)
public class GearboxTestDbContext : DbContext
{
    public DbSet<TestProject> TestProjects { get; set; }
    public DbSet<User> Users { get; set; }
    public DbSet<ProjectParameter> ProjectParameters { get; set; }
    public DbSet<TestTemplate> TestTemplates { get; set; }
    public DbSet<TemplateStep> TemplateSteps { get; set; }
    public DbSet<StepParameterValue> StepParameterValues { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        const string connectionString = "Server=81.70.27.42;Database=transmission;Port=8306;Uid=sa;Pwd=W1717@sina.com;";

        // 使用 Pomelo 的 UseMySql 提供程序
        // ServerVersion.AutoDetect 会自动检测MySQL版本，非常方便
        optionsBuilder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString));
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // 这里可以添加更复杂的配置
        base.OnModelCreating(modelBuilder);
    }
}